<template>
<a-card :bordered="false">
    <div class="table-operator">
        <a-button shape="round" size="small" type="primary" icon="plus" @click="addMenu">新增</a-button>
    </div>
    <LTable
        ref="menuList"
        size="middle"
        rowKey="keyId"
        :columns="columns"
        :initQuery="initQuery"
        axiosUrl="/SysMenuController/queryMenuTableTree"
        :showPagination="false"
        :showQueryForm="false"
        :isAutoLoad="true"
    >
        <span slot="action" slot-scope="text, record">
            <a @click="handleEdit(record,'menuForm',record.menuTitle)">编辑</a>
            <a-divider type="vertical" />
            <a @click="handleEdit(record,'menuButtonList',record.menuTitle)"><a-icon type="setting" />按钮设置</a>
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId},'/SysMenuController/del','menuList')">
                <a>删除</a>
            </a-popconfirm>
            
        </span>
        
    </LTable>
    <menuForm ref="menuForm" @close="refresh('menuList')" @ok="refresh('menuList')"></menuForm> 
    <menuButtonList ref="menuButtonList"></menuButtonList>

    
</a-card>
    
</template>

<script>
import LTable from '@/components/lt/LTable'
import menuForm from './menuForm'
import menuButtonList from './menuButtonList'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'

export default {
    name:'menuList',
    components: {
        LTable,
        menuForm,
        menuButtonList
    },
    mixins:[SysMixin],
    data(){
        return{
            defaultSettings,
            initQuery:[{field:'systemNo',val:defaultSettings.systemNo}],
            columns:[
                {
                    title: '标题',
                    dataIndex: 'menuTitle'
                },
                {
                    title: '路径',
                    dataIndex: 'menuPath', 
                },
                {
                    title: '组件',
                    dataIndex: 'menuComponent'
                },
              
                {
                    title: '模块',
                    dataIndex: 'systemNo',
                    
                },
                
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '220px',
                    scopedSlots: { customRender: 'action' }
                }
            ]

        }
    },
    methods:{
        addMenu(){
            this.handleEdit({systemNo:defaultSettings.systemNo},'menuForm','新增')
        }
    },
  
    
}
</script>